package sctu.edu.java.year2016.team06.yuweimei.day20160601.chapter10_3;

import sctu.edu.java.year2016.team01.xuhanmei.day20160524.practice4.Stringbuild;
import sctu.edu.java.year2016.team08.yangying.day20160527.chapter7_1.S;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * 创建Map集合，创建Emp对象，并将创建的Emp对象添加到集合中（Emp对象的id作为Map集合的键），并将id为005的对象从集合中移除。
 * Created by asus on 2016/6/1.
 */
public class TianJia {
    public static void main(String[] args) {
        Map a = new HashMap();
        Emp emp = new Emp("001", "luo xin");
        Emp emp1 = new Emp("003", "cheng qiang");
        Emp emp2 = new Emp("002", "liu chuanjiao");
        Emp emp3 = new Emp("004", "lv jiafu");
        Emp emp4 = new Emp("005", "yu weimei");
        a.put(emp.getId(), emp.getName());
        a.put(emp1.getId(), emp1.getName());
        a.put(emp2.getId(), emp2.getName());
        a.put(emp3.getId(), emp3.getName());
        a.put(emp4.getId(), emp4.getName());
        Set set = a.keySet();
        Iterator it = set.iterator();
        System.out.println("Emp对象添加后的集合为：");
        while (it.hasNext()) {
            String b = (String) it.next();
            String c = (String) a.get(b);
            System.out.println(b + " " + c);

        }
        a.remove("005");

        System.out.println("id为005的对象移除后的集合为：" + a);


    }
}



